package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.BjBean
import com.haoshuang.zhouzhoubang.model.bean.WxPayBean
import com.haoshuang.zhouzhoubang.model.bean.ZfbBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class BondViewModel55 : BaseViewModel() {
    val getData = StatefulMutableLiveData<ArrayList<BjBean>>()
    fun getData(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ArrayList<BjBean>>("/api/team/get_bu_deposit_skill_list", *params,
                onStart = {
                    getData.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData.value = StateData.Success(it)
                })
        }
    }

    val getData2 = StatefulMutableLiveData<ZfbBean>()
    fun getData2(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ZfbBean>("/api/Skill/skill_create_order", *params,
                onStart = {
                    getData2.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData2.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData2.value = StateData.Success(it)
                })
        }
    }

    val getData3 = StatefulMutableLiveData<WxPayBean>()
    fun getData3(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<WxPayBean>("/api/Skill/skill_create_order", *params,
                onStart = {
                    getData3.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData3.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData3.value = StateData.Success(it)
                })
        }
    }
}